callCollect = function(x , y = NULL, collect = 5, plot = T, ...){
       
        #In all cases x and y can be passed in as a two column matrix
        #of the form cbind(x,y)
        #
        #Case 1:  
        #   collect = 1 
        #   x is a vector 
        #   y = NULL
        #   THEN
        #       -Nothing happens
        #Case 2: 
        #   collect > 1
        #   x is a vector 
        #   y = NULL
        #   THEN
        #       -xc is returned with a length: length(x)-collect
        #Case 3:
        #   collect is an integer vector
        #   x is a vector 
        #   y = NULL
        #   THEN
        #       -not supported
        #Case 4:
        #   collect > 1 
        #   x is a matrix of the form cbind(x,y)
        #   OR
        #   x is a vector of independent values
        #   y is a vector of dependent values
        #   THEN
        #       -sums are preformend on the previous collect days in x
        #       -a list is returned with xc, the corresponding elements in y
        #        and correlation coefficient 
        #Case 5:
        #   collect is an integer vector 
        #   x is a matrix of the form cbind(x,y)
        #   OR
        #   x is a vector of independent values
        #   y is a vector of dependent values
        #   THEN
        #       -sums are preformed for every value of collect 
        #       -a vector of correlation coefficients are returned
        #       -if plot=T then a plot is generated of r vs. collect
        
    if(!is.vector(x)){
        y = x[,2]
        x = x[,1]
    }

    if(length(collect)==1 & collect[1]==1 & is.null(y)){
        warning("A sum length of 1 and no y vector does nothing")
        return(NULL)
    }

    n = length(x)
    r = vector('numeric',length(collect))
    q = 0

    for(j in collect){
        q = q + 1
        xc = vector('numeric',(n-j))

        #cat('j=',i,'\n')
        for(i in j:n){
            #cat(' i=',)
            xc[i-j+1] = sum(x[(i-j+1):i])
        }
        if(!is.null(y)) r[q] = cor(xc,y[j:n])
    }
    if(length(collect)==1){
        if(is.null(y)) return(xc)
        if(!is.null(y) & collect==1) return(r)
        if(!is.null(y) & collect>1) return(list(xc=xc,y=y[j:n],r=r))
    }
    if(length(collect)>1){
        if(plot) plot(collect,r,type="l",xlab="Collection length",ylab="Correlation coefficient",...)
        return(list(r=r))
    }
}




